import { Component } from "@angular/core"
import { NavController } from 'ionic-angular'
import { HttpClient } from '@angular/common/http';
import { NativeStorage } from '@ionic-native/native-storage';
import { TranslateService } from '@ngx-translate/core';

import { AppConfig } from '../../../app/app.config'

import { ToVerifyPage } from './toVerify/toVerify'
@Component({
    selector: 'page-verify',
    templateUrl: 'verify.html',
})

export class VerifyPage{
    
    info={
        certification:-1,
        certification_type:1
    }
    constructor(
        private navCtl:NavController,
        private http:HttpClient,
        private storage:NativeStorage,
        private translate: TranslateService
    ){
        translate.setDefaultLang('en')
    }
    ionViewDidEnter(){
        this.storage.getItem('lang').then(res=>{
            this.translate.use(res)
        })
    }
    ionViewDidLoad(){
        this.storage.getItem('token').then(token=>{
            this.http.get(AppConfig.getUrl()+'user/check?token='+token).subscribe(res=>{
                if(res['code'] == 101){
                    this.info.certification =  res['data']['certification'];
                    this.info.certification_type =  res['data']['certification_type'];
                }
            })
        })
    }
    goto(type){
        if(this.info.certification!=1){
            this.navCtl.push(ToVerifyPage,{type:type});
        }
    }
}